-- DialogueTemplateM
-- Create by chendh Dec/19/2015
-- 对话模板模块

module("DialogueTemplateM", package.seeall);

local dialogueTemplateTable = {};

-- 载入配置表
local _init = false;
local loadCsv = function()
    if _init then return end
    _init = true;

    dialogueTemplateTable = {};

    -- 转换talk_template_CSV表
    local dialogue_template_CSV = get_dialogue_template_CSV();
    for i = 1, #dialogue_template_CSV do
        local row = dialogue_template_CSV[i];

        dialogueTemplateTable[row["talk_template"]] = dialogueTemplateTable[row["talk_template"]] or {};

        dialogueTemplateTable[row["talk_template"]][row["order"]] = row;
    end

    dialogue_template_CSV = {};
end

-- 模块初始化
function init()
    loadCsv();
end

function query(templateId, order)
    local m = dialogueTemplateTable[templateId];

    if not m or not order then
        return m;
    end

    return m[order];
end



